home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
prog_bas
/
pbc32.zip
/
PBC$BAS.ZIP
/
BINSEEKD.BAS
< prev
next >
Wrap
BASIC Source File
|
1996-04-10
|
1KB
|
39 lines
' +----------------------------------------------------------------------+
' | |
' | PBClone (C) Copyright 1996 Charon Software, All Rights Reserved |
' | |
' +----------------------------------------------------------------------+
SUB BinSeekD (Array#(), Elements%, Target#, Posn%)
IF Elements% = 0 THEN
Posn% = -1
ELSE
Top% = 1
Bottom% = Elements% + 1
OldPlace% = Bottom%
DO
Place% = (Top% + Bottom%) \ 2
IF Place% = OldPlace% THEN
NotThere% = -1
ELSEIF Array#(Place%) = Target# THEN
Found% = -1
ELSEIF Array#(Place%) > Target# THEN
Bottom% = Place%
ELSE
Top% = Place%
END IF
OldPlace% = Place%
LOOP UNTIL Found% OR NotThere%
IF NotThere% THEN
IF Elements% = UBOUND(Array#) THEN
Posn% = 0
ELSE
IF Target# > Array#(Place%) THEN Place% = Place% + 1
Posn% = -Place%
END IF
ELSE
Posn% = Place%
END IF
END IF
END SUB